﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Application_Controls_LoggedInUser : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    	TWSUser twsUser = SecurityContext.GetUser();

		if(twsUser!=null)
		{
			LiteralUser.Text = twsUser.FullName;
			LiteralHi.Text = Resources.Resource.Hi;
			LinkButtonSignInOut.Text = Resources.Resource.SignOut;
		}
		else
		{
			LiteralHi.Text = Resources.Resource.Welcome + "!";
			LinkButtonSignInOut.Text = Resources.Resource.SignIn;
		}
    }

	protected void LinkButtonSignInOut_Click(object sender, EventArgs e)
	{
		LinkButton lb = (LinkButton) sender;
		if(lb.Text==Resources.Resource.SignOut)
		{
			SecurityContext.SignOut();
			Response.Redirect(Request.Url.AbsoluteUri);
		}
		else
		{
			//TODO: IMplement send to login
		}
	}
}
